<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //Set数据结构
      let myArr = [1, '1', "a", "a", "b", "c",1,NaN,NaN,undefined,undefined,{},{},[],[]]
      let s = new Set(myArr);
    //   s.add('abc')
    //   s.delete('a')
    //   console.log(s.has('c'));
    // //   s.clear()
    //   console.log(s);
    //   console.log(s.size);

    // function myUnique(arr) {
    //     return Array.from(new Set(arr))
    // }


//    console.log( myUnique(myArr));
   console.log([...new Set(myArr)]);
      //ES5常用的去重方法
      let arr=[1, '1', "a", "a", "b", "c",1,'a'];
      function unique(arr) {
        for (var i = 0; i < arr.length; i++) {
            for (var j = i+1; j < arr.length; j++) {
                if (arr[i]==arr[j]) {
                    arr.splice(j,1);
                    console.log(arr);
                    j--;
                }
            } 
        }
        return arr
      }
      console.log(arr[2]==arr[3]);
      console.log(unique(arr));
    </script>
  </body>
</html>
